package off_transaction

import (
	// "bp/cache"
	sqlc "bp/db/sqlc"
)

type FilterOffTransactionPtrsFunc func(*sqlc.OffTransaction) bool
type FilterOffTransactionDetailPtrsFunc func(*sqlc.OffTransactionDetail) bool
type FilterOffTransactionOfferItemStatPtrsFunc func(*sqlc.OffTransactionOfferItemStat) bool

// FilterOffTrialItemPtrs  []*sqlc.OffTransactionDetail => []*sqlc.OffTransactionDetail
func (s *OffTransactionEntityServiceImp) FilterOffTransactionDetailPtrs(ptrs []*sqlc.OffTransactionDetail, filter FilterOffTransactionDetailPtrsFunc) []*sqlc.OffTransactionDetail {
	if len(ptrs) == 0 {
		return ptrs
	}
	var valPtrs []*sqlc.OffTransactionDetail
	for _, ptr := range ptrs {
		if filter(ptr) {
			valPtrs = append(valPtrs, ptr)
		}
	}
	return valPtrs
}

// FilterOffTrialItemPtrs  []*sqlc.OffTransactionOfferItemStat => []*sqlc.OffTransactionOfferItemStat
func (s *OffTransactionEntityServiceImp) FilterOffTransactionOfferItemStatPtrs(ptrs []*sqlc.OffTransactionOfferItemStat, filter FilterOffTransactionOfferItemStatPtrsFunc) []*sqlc.OffTransactionOfferItemStat {
	if len(ptrs) == 0 {
		return ptrs
	}
	var valPtrs []*sqlc.OffTransactionOfferItemStat
	for _, ptr := range ptrs {
		if filter(ptr) {
			valPtrs = append(valPtrs, ptr)
		}
	}
	return valPtrs
}